package com.yan.kfgl.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.yan.kfgl.model.vo.ShownUser;

public class MainAction {

	private ShownUser user;
	
	public String execute() {
		try {
			HttpServletRequest request = ServletActionContext.getRequest();
			String sessID = request.getSession().getId();
			HttpSession session = request.getSession();

			Map<String, ShownUser> userLogin = (Map<String, ShownUser>) session
					.getAttribute("userLogin");
			if (userLogin == null) {
				userLogin = new HashMap<String, ShownUser>();
				session.setAttribute("userLogin", userLogin);
				return "login";
			} else {
				user = userLogin.get(sessID);
				if (user == null) {
					return "login";
				} else {
					
					return "chainlistJtext";
				}
			}
		} catch (Exception e) {

		}
		return "login";
	}

	public ShownUser getUser() {
		return user;
	}

	public void setUser(ShownUser user) {
		this.user = user;
	}

}
